#include <stdio.h>
#include <string.h>

struct Student // 声明结构体类型struct Student
{
    long num;
    char name[20];
    char sex;
    float score;
};

void addScore1(struct Student p) { 
    p.score += 5; 
}

void addScore2(struct Student *p) { 
    p->score += 5; 
}

int main() {

    struct Student stu_1;         // 定义struct Student类型的变量stu_1
    stu_1.num = 10101;            // 对结构体变量的成员赋值
    strcpy(stu_1.name, "Li Lin"); // 用字符串复制函数给stu_1.name赋值
    stu_1.sex = 'M';
    stu_1.score = 89.5;
    // 输出结果
    printf("No.:%ld\nname:%s\nsex:%c\nscore:%5.1f\n", stu_1.num, stu_1.name,
           stu_1.sex, stu_1.score);

    printf("call addScore1\n");
    addScore1(stu_1);
    printf("No.:%ld\nname:%s\nsex:%c\nscore:%5.1f\n", stu_1.num, stu_1.name,
           stu_1.sex, stu_1.score);

    printf("call addScore2\n");
    addScore2(&stu_1);
    printf("No.:%ld\nname:%s\nsex:%c\nscore:%5.1f\n", stu_1.num, stu_1.name,
           stu_1.sex, stu_1.score);

    return 0;
}
